package com.sheng.controller;


import com.sheng.common.Result;
import com.sheng.common.ResultEnum;
import com.sheng.entity.Menu;
import com.sheng.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王胜
 * @since 2022-11-21 17:16
 */
@RestController
@RequestMapping("/menu")
@Api(tags = "菜单查询接口")
public class MenuController {

    @Autowired
    private IMenuService menuService;

    @GetMapping
    @ApiOperation("根据用户account查询菜单列表")
    public Result getMenuByAccount(HttpServletRequest request){
        String token = request.getHeader("token");
        List<Menu> menus = menuService.getMenusByAccount(token);
        return new Result(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(),menus);
    }
}
